package src.first;

import java.lang.reflect.Constructor;

public class AccessConstructor {

    public static void main(String[] args) {
        try {
            Class<?> aClass = Class.forName("src.first.MoreConstructor");
            Constructor<?>[] constructors = aClass.getDeclaredConstructors();
            for (int i = 0; i < constructors.length; i++) {
                Constructor<?> constructor = constructors[i];
                int modifiers = constructor.getModifiers();
                System.out.println("该构造方法的权限："+modifiers);
                System.out.println("查看是否允许带可变数量的参数："+constructor.isVarArgs());
                Class<?>[] parameters = constructor.getParameterTypes();
                for (int i1 = 0; i1 < parameters.length; i1++) {
                    System.out.print(parameters[i1]+",");
                }
                System.out.println();
                System.out.println("该构造方法可能抛出的异常");
                Class<?>[] exceptionTypes = constructor.getExceptionTypes();
                for (int i1 = 0; i1 < exceptionTypes.length; i1++) {
                    System.out.println(exceptionTypes[i]+",");
                }
                System.out.println();


            }

        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }

    }
}
